package com.my.internetplus.controller;

import com.my.internetplus.dao.AddressDao;
import com.my.internetplus.model.Address;
import com.my.internetplus.model.Order;
import com.my.internetplus.result.BaseResult;
import com.my.internetplus.service.AddressService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class AddressController {

    @Resource
    private AddressService addressService;

    @RequestMapping("addAddress")
    public void addAddress(String name,String phone,String gpsAddr,String describe,String openid){

        addressService.addAddress(name,phone.replace("\"",""),gpsAddr,describe,openid);
    }

    @RequestMapping("getAddressList")
    public BaseResult<List<Address>> getAddressList(int userid){
        return BaseResult.success(addressService.getAddressList(userid));
    }

    @RequestMapping("updateAddress")
    public void updateAddress(String name,String phone,String gpsAddr,String describe,String addid){
        addressService.updateAddress(name,phone,gpsAddr,describe,Integer.parseInt(addid));

    }
    @RequestMapping("delectAddress")
    public void delectAddress(int addid){
      addressService.delectAddress(addid);
    }
}
